﻿using LJ.EventBus.HornedSerpent.Transport.Abstractions;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LJ.EventBus.HornedSerpent.Transport.InMemoryQueue.Internal;


public class InMemoryEventBusTransport(IMemoryQueue memoryQueue, ILogger<InMemoryEventBusTransport> logger) : IEventBusTransport
{
    private readonly IMemoryQueue _memoryQueue = memoryQueue;

    private readonly ILogger _logger = logger;

    public  Task SendAsync(EventBusTransportData transportData, CancellationToken cancellationToken = default)
    {
        cancellationToken.ThrowIfCancellationRequested();

        _memoryQueue.Send(transportData);

        _logger.LogDebug("Event message [{messageName}] has been published.", transportData.GetName());

        return Task.CompletedTask;
    }
}